var Tgm = (function(){
    /**
     * Tgm的一些全局变量
     * baseurl：网站基地址
     * tgm 使用 Tgm作为命名空间
     */
    var tgm = {
        name: 'tgm',
    id: 1,
    zIndex: 10000
    };
    return {
        ie: $.browser.msie,
        ie6: $.browser.msie && $.browser.version == '6.0',
        ie7: $.browser.msie && $.browser.version == '7.0',
        get: function(key){
                 var r = tgm[key];
                 if (key == 'zIndex' || key == 'id') {
                     tgm[key] = r + 1;
                 }
                 return r;
             },
    reg: function(name, value){
             Tgm[name] = value;
         },
    set: function(name, value){
             tgm[name] = value;
         },
    id: function(){
            return Tgm.get('name') + Tgm.get('id');
        },
    callback: function(fn, params, scope){
            if (fn) {
                return fn.apply(scope, $.isFunction(params) ? params() : (params || []));
            }
            return true;
        },
     def: function(name, value){
            if (typeof name == 'undefined') {
                return value;
            }
            return name;
        },
	ajax: function(xhrName, params) {
	        var xhr = Tgm.xhr[xhrName];
	        if(xhr) {
	            xhr.abort();
	        };
	        params.dataType = Tgm.def(params.dataType, 'json');
	        Tgm.xhr[xhrName] = $.ajax(params);
	 },
	 xhr: {// 连续点击取最后一个xhr
	 }
    };
})();

Tgm.win = {};//弹窗

Tgm.baseurl = 'localhost/tgm';
/**
 * @name    : Tgm.menuurl
 * @explain : 选股条件左侧菜单
 * @params  : [tabid : 顶部tab编号]   //写死在index.html界面： data-tab_id = "x"
 * @json    : [{"id":1,"name":"成长能力选股","children":[{"id":2,"name":"涨幅度"},{"id":3,"name":"跌幅度"},{"id":4,"name":"成交量"}]},{"id":5,"name":"股价选股"},{"id":6,"name":"其它选股"}]
 */
Tgm.menuurl = 'src/getsubtab.php' ;  
/**
 * @name    : Tgm.conddetailurl
 * @params  : [submenuid:当前菜单编号] 
 * @explain : 条件详细内容 HTML 模板,结构由php生成
 */
Tgm.conddetailurl = 'src/getconddetail.php' ; 

/**
 * @name    : Tgm.resultlisturl
 * @params  : Tgm.CurrCond 由php返回，格式：{"涨幅度":5,"跌幅度":3}
 * @explain : 条件详细内容 HTML 模板,结构由php生成
 * @json    : {"total":100,"thead":[{"id":0,"text":"名称","sort":"none"},{"id":1,"text":"每股收益","sort":"up"},{"id":2,"text":"每股收益","sort":"default"},{"id":3,"text":"每股收益","sort":"default"},{"id":4,"text":"每股收益","sort":"default"},{"id":5,"text":"每股收益","sort":"default"},{"id":6,"text":"每股收益","sort":"default"},{"id":7,"text":"每股收益","sort":"default"},{"id":8,"text":"每股收益","sort":"default"},{"id":9,"text":"每股收益","sort":"default"}],"tbody":[{"id":1001,"color":"red","data":["贵州茅台",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]}],"conddesc":["涨幅创5日/年","涨幅创5日/年","跌幅创5日/年"]}
 * @json_explain : 首次读取记录30条； thead[X].id (排序字段编码); tbody[x].id(当前股票编码); tbody[x].data (当前股票数据); tbody[x].color (当前股票数据显示颜色:red,green,gray) ;conddesc:条件描述
 */
Tgm.resultlisturl = 'src/resultlist.php' ; 

/**
 * @name    : Tgm.resultdetailurl
 * @explain : 股票图表详细信息
 * @params  : {"start"0,"limit":30}   //开始下标，单次数量
 * @json    : [{"id":1001,"color":"red","data":["贵州茅台",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]},{"id":1002,"color":"green","data":["中国银行",12.84,11,55,45,88,1.1,55,20,58]}]
 */
Tgm.resultlistmoreurl = 'src/resultlistmore.php' ; 

/**
 * @name    : Tgm.resultdetailurl
 * @explain : 股票图表详细信息
 * @params  : [id : 股票编号]   //股票编号
 * @json    : {"id":232311,"name":"贵州茅台","chart":"themes/default/images/charts/c1.jpg","info":[{"name":"开盘价","value":"15.0"},{"name":"昨收价","value":"15.9"},{"name":"最高价","value":"15.9"},{"name":"最低价","value":"15.0"},{"name":"总量","value":"12129"},{"name":"金额","value":"1512121"}]}
 */
Tgm.resultdetailurl = 'src/resultdetail.php' ; 

/**
 * @name    : Tgm.managercondlist
 * @explain : 选股管理条件列表 
 * @params  : [id : 分组编码]   //
 * @json    :[{"id":1,"desc":"成交量>5日/年"},{"id":2,"desc":"成交量>5日/年"},{"id":3,"desc":"成交量>5日/年"},{"id":4,"desc":"成交量>5日/年"},{"id":5,"desc":"成交量>5日/年"}]
 */
Tgm.managercondlisturl = 'src/managercondlist.php' ; 

/**
 * @name    : Tgm.modifycond
 * @explain : 选股管理条件列表 
 * @params  : [id : 分组编码]   //
 * @json    :[{"id":1,"desc":"成交量>5日/年"},{"id":2,"desc":"成交量>5日/年"},{"id":3,"desc":"成交量>5日/年"},{"id":4,"desc":"成交量>5日/年"},{"id":5,"desc":"成交量>5日/年"}]
 */
Tgm.modifycondurl = 'src/modifycond.php' ; 
/**
 * @name    : Tgm.resulturl
 * @explain : 执行结果 
 * @params  : [id : 分组编码]   //

 */
Tgm.resulturl = 'result.html' ; 

/**
 * @name    : Tgm.savecondurl
 * @explain : 保存选股条件 
 * @params  : {"id":5,"val":123}  //
 * @return  : {"success":true}
 */
Tgm.savecondurl = "src/savecond.php" ;


/**
 * @name    : Tgm.delcondurl
 * @explain : 删除选股条件 
 * @params  : {"id":5}  //
 * @return  : {"success":true}
 */
Tgm.delcondurl = "src/savecond.php" ;

